function flushCode(object) {
    // document.getElementById("getCode").src = "/code?date=" + new Date();
    // object.src="/code?date=" + new Date();
    $(object).attr("src", "http://localhost:8088/code?date=" + new Date());
}

function login() {
    let username = $("#username").val();
    let password = $("#password").val();
    let code = $("#code").val();
    let reg = /^[a-zA-Z]\w{5,15}$/;
    if (!reg.test(username)) {
        alert("你输入用户名的格式不正确!");
        return;
    }
    if (!reg.test(password)) {
        alert("你输入密码的格式不正确!");
        return;
    }
    let data = myAjax("/login", {username: username, password: password, code: code}, "post");
    console.log(data);
    if (data == 1) {
        window.location.href = "/back/manage.html";
        $.cookie("token", username);
    } else if (data == 2) {
        alert("验证码不正确");
    } else {
        alert("你输入的用户名或者密码不正确");
    }

}